#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
void Func(int N) {
	int count = 0;
	for (int k = 0; k < 2 * N * N; ++k) {
		++count;
	}
	int M = 10;
	while (M--) {
		++count;
	}
	printf("%d\n", count);
}


int* runningSum(int* nums, int numsSize, int* returnSize)
{
	int ret = 0;
	int* news = (int*)calloc(numsSize, 4);
	for (int i = 0; i < numsSize; i++)
	{
		ret += nums[i];
		news[i] = ret;
	}
	*returnSize = numsSize;
	return news;
}

int searchInsert(int* nums, int numsSize, int target)
{
    int left = 0;
    int right = left + 1;

    while (right < numsSize)
    {
        if (nums[left]<target && nums[right] > target)
        {
            return right;
        }
        else if (nums[left] == target)
        {
            return left;
        }
        else if (nums[right] == target)
        {
            return right;
        }

        left++;
        right++;
    }
    if (target < nums[0])
        return 0;
    if (target > nums[numsSize - 1])
        return numsSize;

    return 0;
}

int main()
{
	int arr[4] = { 1,3,5,6 };
	printf("%d",searchInsert(arr, 4, 0));
	return 0;
}